using System;
using ProjectSurvival.System.Save;
using UnityEngine;
using QFramework;
using UnityEditor;

namespace ProjectSurvival
{
    public partial class RestTestValue : ViewController,IController
    {
        private CoinUpgradeSystem _coinUpgradeSystem;
        private SaveSystem _saveSystem; 
        private void Start()
        {
            _coinUpgradeSystem = this.GetSystem<CoinUpgradeSystem>();
            _saveSystem = this.GetSystem<SaveSystem>();
        }

        private void Update()
        {
            if (Input.GetKeyDown(KeyCode.R))
            {
                Global.CoinPercent.Value = 0.1f;
                Global.ExpPercent.Value = 0.4f;
                Global.Coin.Value = 4;
                
                foreach (var coinUpgradeItem in _coinUpgradeSystem.CoinUpgradeItems)
                {
                    _saveSystem.SaveBool(coinUpgradeItem.Key,false);
                }
                
                Debug.Log($"已重置！\r\nCoinPercent:{Global.CoinPercent.Value}" +
                          $"\r\nExpPercent:{Global.ExpPercent.Value}"+
                          $"\r\nCoin:{Global.Coin.Value}" );
            }

            if (Input.GetKeyDown(KeyCode.KeypadPlus))
            {
                Global.Coin.Value += 10;
            }

            if (Input.GetKeyDown(KeyCode.Z))
            {
                
                //测试用生成炸弹
                GeneratePowerUpManager.Instance.Bomb.Instantiate()
                    .Position(Player.Instance.transform.position+Vector3.left*2)
                    .Show();
            }
            if (Input.GetKeyDown(KeyCode.E))
            {
                
                //测试用生成炸弹
                GeneratePowerUpManager.Instance.PickAllExp.Instantiate()
                    .Position(Player.Instance.transform.position+Vector3.left*2)
                    .Show();
            }

            if (Input.GetKeyDown(KeyCode.G))
            {
                Global.Coin.Value += 100;
            }

            if (Input.GetKeyDown(KeyCode.Q))
            {
                GeneratePowerUpManager.Instance.Treasure.Instantiate()
                    .Position(Player.Instance.transform.position + Vector3.left * 2)
                    .Show();
            }
        }

        public IArchitecture GetArchitecture()
        {
            return Global.Interface;
        }
    }
}